﻿Public Class FormDisplay

    Private m_XboxInfo As DMXIProxy.XboxInfo

    Private Sub New(ByVal XboxInfo As DMXIProxy.XboxInfo)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        m_XboxInfo = XboxInfo
    End Sub

    Friend Shared Sub ShowXboxLiveStatus(ByVal XboxInfo As DMXIProxy.XboxInfo)
        Dim x As New FormDisplay(XboxInfo)
        x.ShowDialog()
    End Sub

    Private Sub FormDisplay_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If m_XboxInfo Is Nothing Then
            ' Do nothing
        Else
            Dim n As TreeNode
            '-------------
            n = Me.ux_TreeView.Nodes.Add(m_XboxInfo.Gamertag)
            nbuild_XboxInfo(n, m_XboxInfo)
            nbuild_XboxLivePresenceInfo(n, m_XboxInfo.PresenceInfo)
            nbuild_XboxUserGameInfo(n, m_XboxInfo.RecentGames)
            '-------------
        End If
    End Sub

    Private Sub nbuild_XboxInfo(ByVal Node As TreeNode, ByVal XboxInfo As DMXIProxy.XboxInfo)
        Dim n As TreeNode
        '-------------
        n = Node.Nodes.Add("Account Status")
        n.Nodes.Add(XboxInfo.AccountStatus.ToString)
        '-------------
        n = Node.Nodes.Add("Country")
        n.Nodes.Add(XboxInfo.Country)
        '-------------
        n = Node.Nodes.Add("GamerScore")
        n.Nodes.Add(XboxInfo.GamerScore)
        '-------------
        n = Node.Nodes.Add("ProfileUrl")
        n.Nodes.Add(XboxInfo.ProfileUrl)
        '-------------
        n = Node.Nodes.Add("Reputation")
        n.Nodes.Add(XboxInfo.Reputation)
        '-------------
        n = Node.Nodes.Add("ReputationImageUrl")
        n.Nodes.Add(XboxInfo.ReputationImageUrl)
        '-------------
        n = Node.Nodes.Add("State")
        n.Nodes.Add(XboxInfo.State.ToString)
        '-------------
        n = Node.Nodes.Add("TileUrl")
        n.Nodes.Add(XboxInfo.TileUrl)
        '-------------
        n = Node.Nodes.Add("Zone")
        n.Nodes.Add(XboxInfo.Zone)
        '-------------
    End Sub

    Private Sub nbuild_XboxLivePresenceInfo(ByVal Node As TreeNode, ByVal XboxLivePresenceInfo As DMXIProxy.XboxLivePresenceInfo)
        Dim TopNode As TreeNode = Node.Nodes.Add("Presence Info")
        Dim n As TreeNode
        '-------------
        n = TopNode.Nodes.Add("Info")
        n.Nodes.Add(XboxLivePresenceInfo.Info)
        '-------------
        n = TopNode.Nodes.Add("Info2")
        n.Nodes.Add(XboxLivePresenceInfo.Info2)
        '-------------
        n = TopNode.Nodes.Add("LastSeen")
        n.Nodes.Add(XboxLivePresenceInfo.LastSeen)
        '-------------
        n = TopNode.Nodes.Add("Online")
        n.Nodes.Add(XboxLivePresenceInfo.Online.ToString)
        '-------------
        n = TopNode.Nodes.Add("StatusText")
        n.Nodes.Add(XboxLivePresenceInfo.StatusText)
        '-------------
        n = TopNode.Nodes.Add("Title")
        n.Nodes.Add(XboxLivePresenceInfo.Title)
        '-------------
        n = TopNode.Nodes.Add("Valid")
        n.Nodes.Add(XboxLivePresenceInfo.Valid.ToString)
        '-------------
    End Sub

    Private Sub nbuild_XboxUserGameInfo(ByVal Node As TreeNode, ByVal XboxUserGameInfo() As DMXIProxy.XboxUserGameInfo)
        Dim TopNode As TreeNode = Node.Nodes.Add("User Game Info")
        For Each UserGame As DMXIProxy.XboxUserGameInfo In XboxUserGameInfo
            Dim gamenode As TreeNode
            gamenode = TopNode.Nodes.Add(UserGame.Game.Name)
            Dim n As TreeNode
            '-------------
            n = gamenode.Nodes.Add("LastPlayed")
            n.Nodes.Add(UserGame.LastPlayed.ToString)
            '-------------
            n = gamenode.Nodes.Add("Achievements")
            n.Nodes.Add(UserGame.Achievements.ToString)
            '-------------
            n = gamenode.Nodes.Add("DetailsURL")
            n.Nodes.Add(UserGame.DetailsURL.ToString)
            '-------------
            n = gamenode.Nodes.Add("GamerScore")
            n.Nodes.Add(UserGame.GamerScore.ToString)
            '-------------
            n = gamenode.Nodes.Add("TotalAchievements")
            n.Nodes.Add(UserGame.Game.TotalAchievements.ToString)
            '-------------
            n = gamenode.Nodes.Add("TotalGamerScore")
            n.Nodes.Add(UserGame.Game.TotalGamerScore.ToString)
            '-------------
        Next
    End Sub



End Class